package com.wink.file.center.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * web mvc配置
 * 图片绝对地址与虚拟地址映射
 *
 * @author wink
 * @date 2020/11/18 13:51:42
 */

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    /**
     * 配置虚拟文件路径
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //文件磁盘图片url 映射
        //配置server虚拟路径，handler为前台访问的目录，locations为files相对应的本地路径
        registry.addResourceHandler("/file/**")
                .addResourceLocations("file:/"+LocalOSSConfig.path);
    }

}